﻿using IXION.BLOG.DOMAIN.TAG;
using System;
using System.Collections.Generic;
using System.Web;

namespace IXION.BLOG.WEB.UI
{
    /// <summary>
    /// 用于处理一下page均需要处理的逻辑 比如加载博客基本信息 获取页码等 持有一下页码需要的变量 比如正则表达式
    /// </summary>
    public class PageBase:System.Web.UI.Page
    {
        protected IXION.BLOG.DOMAIN.BLOG.Blog blog;
        protected string REG_PAGE = "^\\d{1,10}$";
        protected override void OnInit(EventArgs e)
        {
            blog = Application["Blog"] as IXION.BLOG.DOMAIN.BLOG.Blog;
        }
        /// <summary>
        /// 标签的显示方式
        /// </summary>
        /// <param name="o"></param>
        /// <returns></returns>
        public string ConvertToTags(object o)
        {
            string target = "";
            IList<Tag> tags = o as IList<Tag>;
            if (tags == null || tags.Count == 0)
            {
                return "没有标签";
            }
            foreach (Tag tag in tags)
            {
                target += "<a href='Tag.aspx?id=" + tag.Id + "'>" + tag.Name + "</a> | ";
            }
            target = target.Substring(0, target.Length - 1);
            return target;
        }
    }
}